<template>
	<!-- 添加车辆 -->
	<view class="addCar">
		<u-navbar title="车主认证" title-color="#333" back-icon-color="#333"></u-navbar>
		<view class="addCar-bottom">
			<view class="addCar-content-box">
				<!--  -->
				<view class="addCar-carName-phone">

					<!-- <u-tabs :list="list1" bar-width='80' bar-height="50" :show-bar="false" :is-scroll="false" :current="current" @change="change"></u-tabs> -->
					<view>
						<u-radio-group v-model="cx" @change="radioGroupChange">
							<text class="addCar-phone">车型：</text>
							<u-radio @change="radioChange" v-for="(item, index) in list1" :key="index" :name="item.name"
								:disabled="item.disabled" :checked="item.checked">
								{{item.name}}
							</u-radio>
						</u-radio-group>
						</checkbox-group>
					</view>
				</view>
				<view class="msg-tit">行驶证</view>
				<view class="addCar-carName-phone xsz-img-box">
					<view v-if="xsimg.length =='0'" class="bor-kuang">
						<text class="addCar-phone" style="width:auto;">行驶证正面</text>
						<text class="bishu">(必选)</text>
						<view class="" @click="imgSect('z')">
							<image v-if="xsimg.length =='0'" class="add-img-vie" src="../../static/images/add-img.png"
								mode="widthFix"></image>
							<!-- <image v-if="xsimg.length >'0'" class="add-img-vie" :src="xsimg[0]" mode="widthFix"></image> -->

						</view>
					</view>
					<view v-if="xsimg.length >'0'" class="xsimg-box">
						<view class="">
							<image class="sximg-show" @click="preview(xsimg)" :src="xsimg" mode="widthFix"></image>
							<!-- 移除图片的按钮  -->
							<view class="q-image-remover" @click="deleteImgzfm('z')">
								<!-- <image class="deldete" src=""  mode="widthFix"></image> -->
								<uni-icons type="trash" color="#FF3333" size="15"></uni-icons>
							</view>
						</view>
					</view>
					<view v-if="xsimgfm.length =='0'" class="bor-kuang">
						<text class="addCar-phone" style="width:auto;">行驶证副面</text>
						<text class="bishu">(必选)</text>
						<view class="" @click="imgSect('f')">
							<image class="add-img-vie" src="../../static/images/add-img.png" mode="widthFix"></image>
							<!-- <image class="add-img-vie" :src="xsimg" mode="widthFix"></image> -->
						</view>
					</view>
					<view v-if="xsimgfm.length >'0'" class="xsimg-box">
						<view class="">
							<image class="sximg-show" @click="preview(xsimgfm)" :src="xsimgfm" mode="widthFix"></image>
						</view>
						<!-- 移除图片的按钮  -->
						<view class="q-image-remover" @click="deleteImgzfm('f')">
							<!-- <image class="deldete" src=""  mode="widthFix"></image> -->
							<uni-icons type="trash" color="#FF3333" size="15"></uni-icons>
						</view>
					</view>
					<!-- <uni-file-picker fileMediatype="image" :image-styles="imageStyles"/> -->
				</view>
				<view class="msg-cl-xinxi">
					<view class="msg-tit">
						请确认行驶证信息
					</view>
					<view class="addCar-carName-phone">
						<text class="addCar-phone">车牌号：</text>
						<!-- <input class="addCar-input-one" type="text" v-model="carNumberIpt"/> -->
						<view class="addCar-phone-car" @click="boardClick">
							{{carNumberIpt}}
							<text></text>
							<i class="addCar-phone-placeholder" v-if="carNumberIpt==''">上传行驶证自动识别</i>
						</view>
					</view>

					<view class="addCar-carName-phone">
						<text class="addCar-phone">车辆注册日期：</text>
						<picker class="addCar-input-one" mode="date" fields="day" :value="zcrq"
							 @change="bindDateChange">
							<view class="uni-input">{{zcrq}}</view>
							<i class="addCar-phone-placeholder" v-if="zcrq==''">上传行驶证自动识别</i>
						</picker>


						<!-- <u-picker class="addCar-input-one" mode="time" :defaultTime="defaultTime" v-model="show" :params="params" end-year="2030"
									@confirm="confirm"></u-picker> -->

						<!-- <input class="addCar-input-one" type="text" placeholder="上传行驶证自动识别"
							v-model="xszzmsbMsg.ORMTB450CA011" maxlength="15" /> -->
					</view>
					<view class="addCar-carName-phone">
						<text class="addCar-phone">总质量（Kg）：</text>
						<input class="addCar-input-one" type="text" placeholder="请输入总质量"
							v-model="xszzmsbMsgfm.ORMTB450CA17" maxlength="15" />
					</view>
					<view class="addCar-carName-phone">
						<text class="addCar-phone">使用性质：</text>
						<input class="addCar-input-one" type="text" placeholder="请输入" v-model="xszzmsbMsg.ORMTB450CA02"
							maxlength="15" />
					</view>
					<view class="addCar-carName-phone">
						<text class="addCar-phone">行驶证所有人类型：</text>
						<picker class="addCar-input-one" @change="bindPickerChange" :value="xszlx" :range="syrlxArray"
							range-key="name">
							<view class="uni-input">{{syrlxArray[xszlx].name}}</view>
						</picker>
						<!-- <input class="addCar-input-one" type="text" placeholder="请输入司机姓名" v-model="nameIpt"
							maxlength="15" /> -->
					</view>
					<view class="addCar-carName-phone">
						<text class="addCar-phone">行驶证所有人：</text>
						<input class="addCar-input-one" type="text" placeholder="请输入" v-model="xszzmsbMsg.ORMTB450CA01"
							maxlength="15" />
					</view>
					<view class="add-phone-main">
						<view class="addCar-carName-phone" v-for="(item, index) in list">
							<text class="addCar-phone">联系方式：</text>
							<input class="addCar-input-one" type="number" @input="phoneIptInput" placeholder="请输入联系方式"
								v-model="item.phone" maxlength="11" />
							<span style="color: red;" v-if="list.length>=2" @click="delItem(item)">删除</span>

						</view>
						<view class="add-phone" @click="addItem">添加</view>
					</view>
				</view>
				<view class="bishu">
					联系方式仅用于司机接收提货码使用
				</view>

				<view class="addCar-carName-phone xsz-img-box">
					<view v-if="jsimg.length =='0'" class="bor-kuang">
						<text class="addCar-phone" style="width:auto;">上传驾驶证正面</text>
						<text class="bishu">(必选)</text>
						<view class="" @click="imgSect('jsz')">
							<image class="add-img-vie" src="../../static/images/add-img.png" mode="widthFix"></image>
							<!-- <image class="add-img-vie" :src="xsimg" mode="widthFix"></image> -->
						</view>
					</view>
					<view v-if="jsimg.length >'0'" class="xsimg-box">
						<view class="">
							<image class="sximg-show" @click="preview(jsimg)" :src="jsimg" mode="widthFix"></image>
							<!-- 移除图片的按钮  -->
							<view class="q-image-remover" @click="deleteImgzfm('jsz')">
								<!-- <image class="deldete" src=""  mode="widthFix"></image> -->
								<uni-icons type="trash" color="#FF3333" size="15"></uni-icons>
							</view>
						</view>
					</view>
					<!-- <uni-file-picker fileMediatype="image" :image-styles="imageStyles"/> -->
				</view>
				<view class="addCar-carName-phone">
					<text class="addCar-phone">初次领证日期：</text>
					<picker class="addCar-input-one" mode="date" fields="day" :value="lzrq" :start="startDate"
						:end="endDate" @change="bindDateClChange">
						<view class="uni-input">{{lzrq}}</view>
						<i class="addCar-phone-placeholder" v-if="lzrq==''">上传驾驶证自动识别</i>
					</picker>
					<!-- <input class="addCar-input-one" type="text" placeholder="上传驾驶证自动识别"
						v-model="jszzmsbMsg.ORMTB450CA31" maxlength="15" /> -->
				</view>
				<view class="addCar-carName-phone">
					<text class="addCar-phone">有效期限截至日期：</text>
					<picker class="addCar-input-one" mode="date" fields="day" :value="yxrq" :start="startDate"
						:end="endDate" @change="bindDateYxChange">
						<view class="uni-input">{{yxrq}}</view>
						<i class="addCar-phone-placeholder" v-if="yxrq==''">上传驾驶证自动识别</i>
					</picker>
					<!-- input class="addCar-input-one" type="text" placeholder="上传驾驶证自动识别"
						v-model="jszzmsbMsg.ORMTB450CA27" maxlength="15" /> -->
				</view>
				<view class="addCar-carName-phone">
					<text class="addCar-phone">准驾车型：</text>
					<input class="addCar-input-one" type="text" placeholder="上传驾驶证自动识别"
						v-model="jszzmsbMsg.ORMTB450CA33" maxlength="15" />
				</view>
				<!-- <view class="addCar-carName-phone">
					<text class="addCar-phone">皮重：</text>
					<input class="addCar-input-one" @input="tareIptInput" placeholder="请输入皮重" type="number"
						v-model="tareIpt" />
					<text class="addCar-dun">吨</text>
				</view> -->
			</view>
			<view class="xy">
				<u-checkbox-group>
				    <u-checkbox v-model="isty" shape="circle">
						<span style="font-size: 28rpx;">勾选表示同意</span>
					</u-checkbox>
				</u-checkbox-group>
				<span class="style" @click="xyTabFun" href="#">《授权说明》</span>
			</view>
			<!--  -->
			
			<view class="addCar-reset-determine">
				<!-- <view class="add-phone" @click="addItem">新增电话</view> -->
				<!-- <view class="addCar-reset" @click="reset">重置</view> -->
				<view class="addCar-determine" @click="determine">提交</view>
			</view>
		</view>
		<u-modal v-model="addCarLoginShow" content="请确认是否添加该车辆" :show-cancel-button="true" @confirm="addCarConfirm">
		</u-modal>
		<u-keyboard ref="uKeyboard" mode="car" @change="carValChange" @backspace="carBackspace" v-model="carshow"
			:mask="false"></u-keyboard>
	</view>
</template>

<script>
	export default {
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				userinfo: JSON.parse(uni.getStorageSync('userinfo')),
				componeryArr: [],
				addressNew: null,
				Index: 0,
				show: false,
				defaultTime: "",
				isty:false,
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: true,
					timestamp: true

				},
				time: '12:01',
				list1: [{
						name: '13米',
						checked: true,
						disabled: false
					},
					{
						name: '7米6',
						checked: false,
						disabled: false
					},
					{
						name: '9米6',
						checked: false,
						disabled: false
					}

				],
				cx: '13米',
				xszlx: 0,
				gsxszsyr: '',
				syrlxArray: [{
					name: "公司"
				}, {
					name: "本人"
				}, {
					name: "公司（挂靠）"
				}],
				current: 0,
				xsimg: '',
				xsimgfm: '',
				jsimg: '',
				imgArr: [],
				zcrq:'',
				lzrq:'',
				yxrq:'',
				xszzmsbMsg: {
					ORMTB450CA03: '',
					ORMTB450CA011: '',
					ORMTB450CA02: '',
					ORMTB450CA01: ''
				},
				xszzmsbMsgfm: {
					ORMTB450CA17: ''
				},
				jszzmsbMsg: {
					ORMTB450CA31: '',
					ORMTB450CA27: '',
					ORMTB450CA33: ''
				},
				single: '',
				diasabledInput: true, //可读不可写
				carNumberIpt: '', //车牌号
				nameIpt: '', //车主姓名
				phoneIpt: '', //联系方式
				tareIpt: '', //联系方式
				addCarLoginShow: false,
				carshow: false,
				show: false,
				carType: '',
				list: [{
					phone: ''
				}]
			}
		},
		onShow() {},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		methods: {
			xyTabFun(){
				uni.navigateTo({
					url: '/pages/agreement/index'
				})
			},
			confirm(params) {
				console.log(params)

			},
			change(index) {
				this.current = index;
			},
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.detail.value)
				this.xszlx = e.detail.value
			},
			bindDateChange: function(e) {
				console.log(e.detail.value)
				var dateStr = e.detail.value.replace(/\-/g, "");
				this.zcrq = dateStr
			},
			bindDateClChange: function(e) {
				console.log(e.detail.value)
				var dateStr = e.detail.value.replace(/\-/g, "");
				this.lzrq = dateStr
			},
			bindDateYxChange: function(e) {
				console.log(e.detail.value)
				var dateStr = e.detail.value.replace(/\-/g, "");
				this.yxrq = dateStr
			},
			getDate(type) {
				const date = new Date();

				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 10;
				} else if (type === 'end') {
					year = year + 10;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;

				return `${year}-${month}-${day}`;
			},

			changelx(e) {
				console.log("e:", e);
			},
			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				// console.log(e);
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				// console.log(e);
			},
			// 压缩图片
			getImageInfo(src) {
				let _this = this;
				return new Promise((resolve, reject) => {
					uni.showLoading({
						title: '压缩中...',
						icon: 'none'
					});
					uni.getImageInfo({
						src: src,
						success(res) {
							console.log('压缩前', res);
							let canvasWidth = res.width; //图片原始长宽
							let canvasHeight = res.height;
							let img = new Image();
							img.src = res.path;
							let canvas = document.createElement('canvas');
							let ctx = canvas.getContext('2d');
							canvas.width = canvasWidth / 2;
							canvas.height = canvasHeight / 2;
							console.log(img);
							ctx.drawImage(img, 0, 0, canvasWidth / 2, canvasHeight / 2);
							canvas.toBlob(function(fileSrc) {
								let imgSrc = window.URL.createObjectURL(fileSrc);
								console.log('压缩后', imgSrc);
								resolve(imgSrc);
								uni.hideLoading();
							});
						}
					});
				});
			},
			deleteImgzfm(zf) {
				var _this = this

				uni.showModal({
					title: "删除",
					content: "是否删除该选中的图片！",
					confirmText: "删除",
					success(res) {
						var index1
						var imgdel
						if (zf == 'z') {
							index1 = _this.xsimg.lastIndexOf("2022", "2023")
							imgdel = _this.xsimg.substring(index1)
						}
						if (zf == 'f') {
							index1 = _this.xsimgfm.lastIndexOf("2022", "2023")
							imgdel = _this.xsimgfm.substring(index1)
						}
						console.log(res)
						if (res.confirm) { //删除
							uni.request({
								url: _this.baseUrl + '/system/deleteFile',
								method: 'POST',
								dataType: 'json',
								data: {
									fileName: imgdel
								},
								success: (res) => {
									console.log(res);
									if (res.data.code == 200) {
										uni.showToast({
											title: res.data.message,
											duration: 5000,
											icon: 'none',
										});
										if (zf == 'z') {
											_this.xsimg = ""
										}
										if (zf == 'f') {
											_this.xsimgfm = ""
										}
										if (zf == 'jsz') {
											_this.jsimg = ""
										}


									} else {
										uni.showToast({
											title: res.data.message,
											duration: 5000,
											icon: 'none',
										});
									}
								},
								fail: (res) => {
									uni.showToast({
										title: res.data.message,
										duration: 5000,
										icon: 'none',
									});
								}
							});



						}
					}
				})
			},


			// 预览图片
			preview(img) {
				console.log('预览')
				// 新建一个存放预览图片的空数组
				var imgArr = []
				imgArr.push(img)
				uni.previewImage({
					urls: imgArr,
					current: imgArr[0],
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},

			imgSect(zfm) {
				var _self = this
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['camera', 'album'], //从相册选择
					success: function(res) {
						console.log(res)
						uni.showLoading({
							title: '上传中'
						})
						var tempFilePaths = res.tempFilePaths[0]
						console.log(tempFilePaths)
						var flag
						if (zfm == 'z') {
							flag = 1
						}
						if (zfm == 'f') {
							flag = 2
						}
						if (zfm == 'jsz') {
							flag = 3
						}

						// _self.getImageInfo(res.tempFilePaths[0]).then(res => {
						// console.log(res)
						// tempFilePaths = res
						uni.uploadFile({
							url: _self.baseUrl + '/system/uploadLicense',
							filePath: tempFilePaths,
							formData: {
								//iFile:tempFilePaths[0], // 这里一定不能加,加了 iOS 图片上传会失败
								flag: flag,
							},

							name: 'file',
							success(resdata) {
								console.log(resdata)
								if (resdata.statusCode == 200) {
									uni.hideLoading()
									resdata.data = JSON.parse(resdata.data);

									if (zfm == 'z') {
										_self.xszzmsbMsg = resdata.data.data
										_self.xsimg = _self.xszzmsbMsg.ORMTB450CA04
										if (_self.xszzmsbMsg.ORMTB450CA03) {
											_self.carNumberIpt = _self.xszzmsbMsg.ORMTB450CA03
										}

										if (_self.xszzmsbMsg.ORMTB450CA011) {
											_self.zcrq = _self.xszzmsbMsg.ORMTB450CA011
										}
										if (!_self.xszzmsbMsg.ORMTB450CA02) {
											_self.xszzmsbMsg.ORMTB450CA02 = ""
										}
										if (!_self.xszzmsbMsg.ORMTB450CA01) {
											_self.xszzmsbMsg.ORMTB450CA01 = ""
										}

										return
										// _self.carNumberIpt = _self.xszzmsbMsg.ORMTB450CA03
									}
									if (zfm == 'f') {
										_self.xszzmsbMsgfm = resdata.data.data
										_self.xsimgfm = _self.xszzmsbMsgfm.ORMTB450CA25
										if (!_self.xszzmsbMsgfm.ORMTB450CA17) {
											_self.xszzmsbMsgfm.ORMTB450CA17 = ''
										}
										return
									}
									if (zfm == 'jsz') {
										_self.jszzmsbMsg = resdata.data.data
										_self.jsimg = _self.jszzmsbMsg.ORMTB450CA37
										if (_self.jszzmsbMsg.ORMTB450CA31) {
											_self.lzrq = _self.jszzmsbMsg.ORMTB450CA31
										}
										if (_self.jszzmsbMsg.ORMTB450CA27) {
											_self.yxrq = _self.jszzmsbMsg.ORMTB450CA27
										}
										if (!_self.jszzmsbMsg.ORMTB450CA33) {
											_self.jszzmsbMsg.ORMTB450CA33 = ''
										}

									}
									uni.showToast({
										title: resdata.data.message,
										icon: 'none'
									})
								}
							},
							fail(resdata) {
								uni.hideLoading()
							}
						})

						// });
					}
				});
			},
			// imgSectxszfm() {
			// 	var _self = this
			// 	uni.chooseImage({
			// 		count: 1, //默认9
			// 		sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
			// 		sourceType: ['camera', 'album'], //从相册选择
			// 		success: function(res) {
			// 			console.log(res)
			// 			uni.showLoading({
			// 				title: '上传中'
			// 			})
			// 			var tempFilePaths = res.tempFilePaths[0]
			// 			console.log(tempFilePaths)


			// 			// _self.getImageInfo(res.tempFilePaths[0]).then(res => {
			// 			// console.log(res)
			// 			// tempFilePaths = res
			// 			uni.uploadFile({
			// 				url: _self.baseUrl + '/system/uploadLicense',
			// 				filePath: tempFilePaths,
			// 				formData: {
			// 					//iFile:tempFilePaths[0], // 这里一定不能加,加了 iOS 图片上传会失败
			// 					flag: 2,
			// 				},
			// 				name: 'file',
			// 				success(res) {
			// 					console.log(res)
			// 					if (res.statusCode == 200) {
			// 						uni.hideLoading()
			// 						res.data = JSON.parse(res.data);
			// 						_self.xszzmsbMsgfm = res.data.data
			// 						_self.xsimgfm = _self.xszzmsbMsgfm.ORMTB450CA25
			// 						uni.showToast({
			// 							title: res.data.message,
			// 							icon: 'none'
			// 						})
			// 					}
			// 				},
			// 				fail(res) {
			// 					uni.hideLoading()
			// 				}
			// 			})

			// 			// });
			// 			console.log(JSON.stringify(res.tempFilePaths));
			// 		}
			// 	});
			// },

			addItem() {
				if (this.list.length == 3) {
					uni.showToast({
						title: '最多三个',
						icon: 'none'
					})
					return false
				}
				// let add = {
				// 	id: parseInt(this.id) + 1
				// }
				this.list.push({
					phone: ''
				})
				// this.id = parseInt(this.id) + 1
				// this.phoneIpt += parseInt(this.id) + 1
				console.log(this.list)
			},
			delItem(item) {
				if (this.list.length == 1) {
					uni.showToast({
						title: '不能删除第1个',
						icon: 'none'
					})
					return false;
				}
				this.list = this.list.filter((i) => {
					return i != item
				})
			},
			carValChange(val) {
				// 将每次按键的值拼接到carNumberIpt变量中，注意+=写法
				this.carNumberIpt += val;
			},
			carBackspace() {
				// 删除carNumberIpt的最后一个字符
				if (this.carNumberIpt.length) this.carNumberIpt = this.carNumberIpt
					.substr(0, this.carNumberIpt.length -1);
			},
			boardClick() {
				this.carshow = true
			},
			tareIptInput() { //限制验证码长度
				if (this.tareIpt.length > 6) {
					this.tareIpt = this.tareIpt.slice(0, 6)
				}
			},
			phoneIptInput() {
				if (this.phoneIpt.length > 11) {
					this.phoneIpt = this.phoneIpt.slice(0, 11)
				}
			},
			// 确定
			determine() {
				
				//车牌号
				var regC =
					/^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领])|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][0-9]{2}([0-9]|[A-Z]){5}))$/;
				var regP = /^1[3-9][0-9]{9}$/;
				if (this.xsimg == '') {
					return uni.showToast({
						title: '请上传行驶证正面',
						duration: 5000,
						icon: 'none',
					});
				}
				if (this.xsimgfm == '') {
					return uni.showToast({
						title: '请上传行驶证副面',
						duration: 5000,
						icon: 'none',
					});
				}
				if (!regC.test(this.carNumberIpt)) return uni.showToast({
					title: '车牌号格式不正确，请检查',
					duration: 5000,
					icon: 'none',
				});
				if (this.zcrq == '') {
					return uni.showToast({
						title: '请选择车辆注册日期',
						duration: 5000,
						icon: 'none',
					});
				}



				if (this.xszzmsbMsgfm.ORMTB450CA17 == '') {
					return uni.showToast({
						title: '请输入总质量',
						duration: 5000,
						icon: 'none',
					});
				}
				if (this.xszzmsbMsg.ORMTB450CA02 == '') {
					return uni.showToast({
						title: '请选择使用性质',
						duration: 5000,
						icon: 'none',
					});
				}
				if (this.xszzmsbMsg.ORMTB450CA01 == '') {
					return uni.showToast({
						title: '请输入行驶证所有人',
						duration: 5000,
						icon: 'none',
					});
				}
				for (let index = 0; index < this.list.length; index++) {
					if (this.list[index].phone == '') {
						return uni.showToast({
							title: '请输入手机号',
							duration: 5000,
							icon: 'none',
						});
					}
					if (this.list[index].phone != '') {
						if (!regP.test(this.list[index].phone)) return uni.showToast({
							title: '手机号格式不正确，请检查',
							duration: 5000,
							icon: 'none',
						});
					}
				}
				if (this.jsimg == '') {
					return uni.showToast({
						title: '请上传驾驶证正面',
						duration: 5000,
						icon: 'none',
					});
				}
				if (this.lzrq == '') {
					return uni.showToast({
						title: '请输入初次领证日期',
						duration: 5000,
						icon: 'none',
					});
				}
				if (this.lzrq == '') {
					return uni.showToast({
						title: '请输入有效期限截至日期',
						duration: 5000,
						icon: 'none',
					});
				}
				if (this.jszzmsbMsg.ORMTB450CA33 == '') {
					return uni.showToast({
						title: '请输入准驾车型',
						duration: 5000,
						icon: 'none',
					});
				}
				if (this.xszzmsbMsg.ORMTB450CA02 == '非营运') {
					return uni.showToast({
						title: '请上传营运车辆证件',
						duration: 5000,
						icon: 'none',
					});
				}
				if (this.isty == false) {
					return uni.showToast({
						title: '请勾选授权',
						duration: 5000,
						icon: 'none',
					});
				}
				
				// if(this.phoneIpt ==''){
				// 	return uni.showToast({
				// 		title: '请输入手机号',
				// 		duration: 5000,
				// 		icon: 'none',
				// 	});
				// }


				this.addCarLoginShow = true

			},
			addCarConfirm() {
				if (this.userinfo.sign == 'CUS-1') {
					var ORMTB400ID = this.userinfo.ORMTB400ID
				} else if (this.userinfo.sign == 'CUS-2' || this.userinfo.sign == 'CUS-3') {
					var ORMTB400ID = this.userinfo.ORMTB410ID
				}
				uni.request({
					url: this.baseUrl + '/orm/ormtb450/insertOrmtb450',
					method: 'POST',
					dataType: 'json',
					data: {
						ORMTB450CA03: this.carNumberIpt,/*车牌号*/
						ORMTB450CA00: this.cx,//车型
						ORMTB450CA01: this.xsimg,/*行驶证正面url*/
						ORMTB450CA02: this.xsimgfm,/*行驶证背面url*/
						ORMTB450CA05: this.xszlx,/*行驶证所有人类型*/
						ORMTB450CA06: this.xszzmsbMsg.ORMTB450CA01,/*行驶证所有人*/
						ORMTB450CA07: this.list,/*司机联系方式*/
						ORMTB450CA08: this.jsimg,/*驾驶证url*/
						ORMTB450CA11: this.zcrq,/*车辆注册日期*/
						ORMTB450CA12: this.xszzmsbMsgfm.ORMTB450CA17,/*总质量KG*/
						ORMTB450CA13: this.xszzmsbMsg.ORMTB450CA02,/*使用性质*/
						ORMTB450CA14: this.lzrq,/*初次领证日期*/
						ORMTB450CA15: this.yxrq,/*有效期限截止日*/
						ORMTB450CA16: this.jszzmsbMsg.ORMTB450CA33,/*准驾车型*/
						// SETTB402CA03: this.tareIpt,
						// sign: this.userinfo.sign,
						ORMTB410ID: ORMTB400ID,
					},
					success: (res) => {
						console.log(res);
						if (res.data.code == 200) {
							uni.showToast({
								title: '添加成功',
								duration: 5000,
								icon: 'none',
							});
							uni.navigateBack()
						} else {
							uni.showToast({
								title: res.data.message,
								duration: 5000,
								icon: 'none',
							});
						}
					},
					fail: (res) => {
						uni.showToast({
							title: res.data.message,
							duration: 5000,
							icon: 'none',
						});
					}
				});
			},
			// 重置
			reset() {
				this.carNumberIpt = '' //车牌号
				this.nameIpt = '' //车主姓名
				this.phoneIpt = '' //联系方式
				this.tareIpt = ''
			},
		}
	}
</script>

<style scoped>
	.addCar input {
		border: 0;
	}

	.addCar {
		width: 100%;
		min-height: 100vh;
		background-color: rgba(242, 242, 242, 1);
		overflow: hidden;
	}

	/* 列表 */

	/* 内容 */
	.addCar-content-box {
		width: 100%;
		background: rgba(255, 255, 255, 1);
		padding: 0 24rpx;
	}

	.addCar-carName-phone {
		border-bottom: 2rpx solid rgba(230, 230, 230, 1);
		padding: 18rpx 0;
	}

	.addCar-input-one {
		width: 310rpx !important;
		display: inline-block;
		margin-bottom: 0 !important;
		padding: 0 !important;
		height: 44rpx !important;
		vertical-align: middle;
		/* margin-left: 0.1rem; */
		color: rgba(51, 51, 51, 1);
		font-size: 28rpx;
		text-align: center;
	}

	.addCar-phone {
		width: 241rpx;
		display: inline-block;
		font-size: 30rpx;
		color: rgba(102, 102, 102, 1);
		vertical-align: middle;
		/* background: #000000; */
	}

	.addCar-phone-placeholder {
		font-size: 30rpx;
		color: rgba(102, 102, 102, .5);
	}

	.addCar-dun {
		color: rgba(51, 51, 51, 1);
		font-size: 30rpx;
	}

	/* 按钮 */
	.addCar-reset-determine {
		margin-top: 40rpx;
		margin-bottom: 40rpx;
		display: flex;
		justify-content: center;
	}



	.addCar-reset-determine>view {
		width: 80%;
		text-align: center;
		line-height: 100rpx;
		color: rgba(255, 255, 255, 1);
		font-size: 32rpx;
		border-radius: 20rpx;
	}

	.addCar-reset {
		width: 159rpx;
		background: rgba(234, 197, 15, 1);
		text-align: center;
		/* margin-left: 170rpx; */
		margin: 0 20rpx;
	}

	.addCar-determine {
		background: rgba(0, 161, 244, 1);
		/* margin-left: 60rpx; */
	}

	.add-phone-main {
		position: relative;
	}

	.add-phone {
		position: absolute;
		top: 20rpx;
		right: 0;
		/* font-size: 50rpx; */
		color: rgba(0, 255, 127, 1);
		/* background: rgba(0, 255, 127, 1); */

	}

	.addCar-phone-car {
		display: inline-block;
		width: 310rpx;
		height: 44rpx;
		line-height: 44rpx;
		/* border: 1px solid rgba(0, 0, 0, .2); */
		/* border-radius: 3px; */
		text-align: center;
		vertical-align: middle;
		font-size: 30rpx;
	}

	input::placeholder {
		color: rgba(102, 102, 102, .5);
	}

	.item-box {
		display: flex;
	}

	.uni-label-pointer {
		margin-right: 10rpx;
	}

	.bishu {
		color: red;
	}

	.msg-tit {
		padding-top: 20rpx;
		font-size: 32rpx;
	}

	.msg-cl-xinxi {
		/* margin-top: 10rpx; */
	}

	.add-img-vie {
		width: 50rpx;
		height: 50rpx;
	}

	.bor-kuang {
		border: 2rpx solid #eee;
		text-align: center;
		font-size: 20rpx;
		padding: 20rpx;
	}

	.xsimg-box {
		width: 260rpx;
		height: 142rpx;
		text-align: center;
		/* padding: 20rpx; */
		overflow: hidden;
		position: relative;
	}

	.xsimg-box .sximg-show {
		width: 100%;
		height: 100%;
	}

	.bor-jszkuang {
		width: 200rpx;
		height: 200rpx;
		border: 2rpx solid #eee;
		text-align: center;
		font-size: 20rpx;
		padding: 20rpx;
	}

	.xsz-img-box {
		display: flex;
		justify-content: space-between;

	}

	.q-image-remover {
		/* width: 0;
		height: 0; */
		/* 	border-top: 66rpx solid red;
	border-left: 66rpx solid transparent; */
		width: 30rpx;
		height: 60rpx;
		border-radius: 0 0 0 10rpx;
		/* background-color: red; */
		/* 	border-right: 66rpx solid lightpink;
	border-bottom: 66rpx solid lightsalmon; */
		position: absolute;
		top: 0;
		right: 0rpx;
	}
	.style{
		color: rgba(0, 161, 244, 1);
	}
	.xy{
		padding: 24rpx;
	}
</style>
